package com.gitee.webdav.xml;

import cn.hutool.core.text.CharSequenceUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.gitee.webdav.kernel.Remark;
import lombok.Data;
import lombok.experimental.Accessors;
import org.smartboot.http.common.enums.HttpProtocolEnum;
import org.smartboot.http.common.enums.HttpStatus;

/**
 * @author hongda.li@hand-china.com
 */
@Data
@Accessors(chain = true)
@Remark("属性状态")
public class PropertiesStatus {

    @Remark("属性详情")
    @JacksonXmlProperty(localName = "prop", namespace = "DAV:")
    private Properties properties;

    @Remark("状态详情")
    @JacksonXmlProperty(localName = "status", namespace = "DAV:")
    private String status;

    public PropertiesStatus buildStatus(HttpStatus status) {
        this.status = HttpProtocolEnum.HTTP_11.getProtocol()
                + CharSequenceUtil.SPACE
                + status.value()
                + CharSequenceUtil.SPACE
                + status.getReasonPhrase();
        return this;
    }
}
